package com.example.campuslink.commen.db.invitation

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.Query
import androidx.room.RewriteQueriesToDropUnusedColumns
import androidx.room.Transaction
import androidx.room.Update

@Dao
interface InvitationDao {
    @Query("SELECT MAX(id) FROM invitation_table")
    fun getMaxId(): Int?

    @Transaction
    @Insert
    fun insertInvitation(invitationTable: InvitationTable)

    @Transaction
    @Update
    fun updateInvitation(invitationTable: InvitationTable)

    @Query("SELECT * FROM invitation_table")
    fun getAllInvitation(): List<InvitationTable>


    @RewriteQueriesToDropUnusedColumns
    @Query("SELECT * FROM invitation_table WHERE id = :id AND userNumber = :userNumber")
    fun getInvitationById(id: Int, userNumber: String): InvitationTable?
}